package com.example.abc;

import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;

public class glq {
    public static boolean dl(Context context, String userName, String password) {

        yh yh = getUser(context, userName);

        Log.d("test", yh + "");

        return yh != null && yh.getMm().equals(password);
    }

    public static yh getUser(Context context, String userName) {
        SharedPreferences mm = context.getSharedPreferences("mm", Context.MODE_PRIVATE);

        SharedPreferences nl = context.getSharedPreferences("nl", Context.MODE_PRIVATE);

        SharedPreferences xm = context.getSharedPreferences("xm", Context.MODE_PRIVATE);


        if (!mm.contains(userName)) {

            return null;
        }

        return new yh(userName, mm.getString(userName, null),
                nl.getString(userName, null),
                xm.getInt(userName, -1));
    }

    public static void zhuce(Context context, yh yh) {
        SharedPreferences mm = context.getSharedPreferences("mm", Context.MODE_PRIVATE);

        SharedPreferences nl = context.getSharedPreferences("nl", Context.MODE_PRIVATE);

        SharedPreferences xm = context.getSharedPreferences("xm", Context.MODE_PRIVATE);

        String userName = yh.getYhm();

        SharedPreferences.Editor passwordEditor = mm.edit();

        passwordEditor.putString(userName, yh.getMm());

        passwordEditor.apply();

        SharedPreferences.Editor ageEditor = nl.edit();


        ageEditor.putInt(userName, yh.getNl());

        ageEditor.apply();

        SharedPreferences.Editor nickEditor = xm.edit();

        nickEditor.putString(userName, yh.getMm());

        nickEditor.apply();
    }
}
